<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录 | {:sys_config('site_name', 'DOG - ALBERT3306')}</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" type="text/css" href="{__PLUG_PATH}bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="{__PLUG_PATH}jquery/jquery.min.js"></script>
    <script type="text/javascript" src="{__PLUG_PATH}layer/layer.js"></script>
    <script type="text/javascript" src="{__PLUG_PATH}vue/vue.min.js"></script>
    <script type="text/javascript" src="{__PLUG_PATH}vue/vue-resource.min.js"></script>

    <style>
        body {
            color:#999;
            background:url('{__ADMIN_PATH}images/loginbg.jpg');
            background-size:cover;
        }
        a {
            color:#fff;
        }
        .login-panel{margin-top:150px;}
        .login-screen {
            max-width:400px;
            padding:0;
            margin:100px auto 0 auto;

        }
        .login-screen .well {
            border-radius: 3px;
            -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            background: rgba(255,255,255, 0.2);
        }
        .login-screen .copyright {
            text-align: center;
        }
        @media(max-width:767px) {
            .login-screen {
                padding:0 20px;
            }
        }
        .profile-img-card {
            width: 100px;
            height: 100px;
            margin: 10px auto;
            display: block;
            -moz-border-radius: 50%;
            -webkit-border-radius: 50%;
            border-radius: 50%;
        }
        .profile-name-card {
            text-align: center;
        }

        .login-wrapper .login-content .login-form {
            margin-top:20px;
        }
        .login-wrapper .login-content .login-form .input-group {
            margin-bottom:15px;
        }
    </style>
</head>
<body class="sidebar-mini fixed skin-blue-light">
<div class="container" v-cloak @keyup.enter="submitForm">
    <div class="login-wrapper">
        <div class="login-screen">
            <div class="well">
                <div class="login-content">
                    <img class="profile-img-card" src="/static/images/avatar.png" />
                    <p class="profile-name-card"></p>
                    <div class="login-form">
                        <div class="input-group">
                            <div class="input-group-addon"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></div>
                            <input type="text" class="form-control" placeholder="用户名" v-model="formData.username"/>
                        </div>

                        <div class="input-group">
                            <div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
                            <input type="password" class="form-control" placeholder="密码" v-model="formData.password"/>
                        </div>
                        <div class="input-group">
                            <div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
                            <input type="text" class="form-control" placeholder="验证码" v-model="formData.captcha"/>
                            <span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
                                    <img src="{:captcha_src()}" width="100" height="30" onclick="this.src='{:captcha_src()}' + Math.random()"/>
                                </span>
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-primary btn-lg btn-block" @click="submitForm">登  录</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    let Vue_init = new Vue({
        el: ".container",
        data: {
            formData: {username: '', password: '', captcha: ''}
        },
        methods: {
            submitForm: function () {
                this.$http.post('/admin/login', this.formData).then(function (res) {
                    layer.msg(res.body.msg);
                    if (parseInt(res.body.status) === 200) {
                        window.location.href = '/admin/index';
                    } else {
                        // 更换验证码
                        $('.login-form img').click();
                    }
                }, function (res) {
                    layer.msg(res.statusText);
                });
            }
        }
    });
</script>
</body>
</html>